package org.pine.controller;

import lombok.extern.slf4j.Slf4j;
import org.pine.model.Book;
import org.pine.mybatis.mapper1.BookMapper1;
import org.pine.mybatis.mapper2.BookMapper2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName BookController3
 * @Description:mybatis 多数据源测试
 * @Author liucs
 * @Date 2021-01-28
 * @Version V1.0
 */
@RestController
@Slf4j
public class BookController3 {
    BookMapper1 bookMapper1;
    @Autowired
    public void setBookMapper1(BookMapper1 bookMapper1) {
        this.bookMapper1 = bookMapper1;
    }
    BookMapper2 bookMapper2;
    @Autowired
    public void setBookMapper2(BookMapper2 bookMapper2) {
        this.bookMapper2 = bookMapper2;
    }

    @GetMapping("/testMybatis")
    public void testBook(){
        List<Book> list1=bookMapper1.getBooks();
        log.info("get book by bookMapper1:{}",list1);
        List<Book> list2=bookMapper2.getBooks();
        log.info("get book by bookMapper2:{}",list2);
    }
}
